/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lostreseditores.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author DILOVE
 */
@Entity
@Table(name = "curso")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"),
    @NamedQuery(name = "Curso.findByIdCurso", query = "SELECT c FROM Curso c WHERE c.idCurso = :idCurso"),
    @NamedQuery(name = "Curso.findByNombrecurso", query = "SELECT c FROM Curso c WHERE c.nombrecurso = :nombrecurso"),
    @NamedQuery(name = "Curso.findByJornadacurso", query = "SELECT c FROM Curso c WHERE c.jornadacurso = :jornadacurso")})
public class Curso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_curso")
    private Integer idCurso;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "nombrecurso")
    private String nombrecurso;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "jornadacurso")
    private String jornadacurso;
    @ManyToMany(mappedBy = "cursoList")
    private List<Asignatura> asignaturaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso")
    private List<Premarcado> premarcadoList;
    @JoinColumns({
        @JoinColumn(name = "id_institucion", referencedColumnName = "id_institucion"),
        @JoinColumn(name = "id_grado", referencedColumnName = "id_grado")})
    @ManyToOne(optional = false)
    private Gradoinstitucion gradoinstitucion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso")
    private List<Cursosestudiante> cursosestudianteList;

    public Curso() {
    }

    public Curso(Integer idCurso) {
        this.idCurso = idCurso;
    }

    public Curso(Integer idCurso, String nombrecurso, String jornadacurso) {
        this.idCurso = idCurso;
        this.nombrecurso = nombrecurso;
        this.jornadacurso = jornadacurso;
    }

    public Integer getIdCurso() {
        return idCurso;
    }

    public void setIdCurso(Integer idCurso) {
        this.idCurso = idCurso;
    }

    public String getNombrecurso() {
        return nombrecurso;
    }

    public void setNombrecurso(String nombrecurso) {
        this.nombrecurso = nombrecurso;
    }

    public String getJornadacurso() {
        return jornadacurso;
    }

    public void setJornadacurso(String jornadacurso) {
        this.jornadacurso = jornadacurso;
    }

    @XmlTransient
    public List<Asignatura> getAsignaturaList() {
        return asignaturaList;
    }

    public void setAsignaturaList(List<Asignatura> asignaturaList) {
        this.asignaturaList = asignaturaList;
    }

    @XmlTransient
    public List<Premarcado> getPremarcadoList() {
        return premarcadoList;
    }

    public void setPremarcadoList(List<Premarcado> premarcadoList) {
        this.premarcadoList = premarcadoList;
    }

    public Gradoinstitucion getGradoinstitucion() {
        return gradoinstitucion;
    }

    public void setGradoinstitucion(Gradoinstitucion gradoinstitucion) {
        this.gradoinstitucion = gradoinstitucion;
    }

    @XmlTransient
    public List<Cursosestudiante> getCursosestudianteList() {
        return cursosestudianteList;
    }

    public void setCursosestudianteList(List<Cursosestudiante> cursosestudianteList) {
        this.cursosestudianteList = cursosestudianteList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCurso != null ? idCurso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Curso)) {
            return false;
        }
        Curso other = (Curso) object;
        if ((this.idCurso == null && other.idCurso != null) || (this.idCurso != null && !this.idCurso.equals(other.idCurso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.lostreseditores.modelo.Curso[ idCurso=" + idCurso + " ]";
    }
    
}
